<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="LAFDC.DataAccess" %>
<%@ Import Namespace="LAFDC.Logging" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
    <script language="c#" runat="server">
            public static readonly string source = "RechercheRoutageEx";
            
            protected void Page_Load(object sender, EventArgs e)
            {
                string filterColumn = string.Empty;
                string filterValue = string.Empty;
                
                FDCLogger.LogEvent("Recherche Routage Execution is running now!" , source, 4);

                if (this.Request.Params.Count > 2)
                {
                    FDCLogger.LogEvent("Page is loading with more than 1 parameter", source, 4);
                    filterColumn = Request.Params.Get("Object");
                    filterValue = Request.Params.Get("Valeur");

                    if ((filterColumn != null) && (filterColumn.Length > 0))
                    {
                        string SQLCmd = @"select PREV_ID as 'Prev_ID', Asso as 'AD', DESTINATAIRE, VILLE_CP as 'Code postal, Ville', QUANTITE, SYNCHRONE from ROUTAGE where " + filterColumn + " like '%" + filterValue + "%' ";

                        FDCLogger.LogEvent("Preparing to execute SQL query: " + SQLCmd , source, 3);

                        ConnectionManager cn = new ConnectionManager();
                        SqlDataSource1.ConnectionString = cn.GetConnectionString();

                        SqlDataSource1.SelectCommand = SQLCmd;

                        GridView1.DataBind();
                    }
                }
                if (GridView1.Rows.Count == 0)
                {
                    lblRECHERCHE.Text = "<B>REQUETE EXECUTER - PAS DE RESULTAT DISPONIBLE</B>";
                }
            }
    </script>
<head runat="server">
    <title>Recherche Routage</title>
    <link type="text/css" rel="stylesheet" href="style.css"/>
</head>
<body>
    <form id="form1" runat="server">
         <div id="header">
        <table style="width: 100%">
            <tr style="height: 30px">
                <td style="width: 3%" align="center"><a href="/LAFDCWeb/" target="_parent">
                    <img alt="Accueil" src="images/home_16x16.PNG" border="0" /></a></td>
                <td style="width: 70%">
                    Fichier adherent: Recherche routage
                    <asp:Label ID="Label1" runat="server" Font-Names="Verdana"></asp:Label></td>
                <td style="width: 20%" align="right">
                    <asp:HyperLink ID="imgAdd" runat="server" ImageUrl="images/add.gif" />
                    <asp:HyperLink ID="imgEdit" runat="server" ImageUrl="images/edit.gif"/>
                </td>
            </tr>
        </table>
        <hr />
          <asp:GridView ID="GridView1" AllowSorting="True" AllowPaging="True" runat="server"
            DataSourceID="SqlDataSource1" DataKeyNames="prev_id" PageSize="25"
            AutoGenerateColumns="False" Width="100%" Height="100%" BackColor="White" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" CellPadding="3" ForeColor="Black" GridLines="Vertical">
            <Columns>
            <asp:HyperLinkField HeaderText="Consultation routage" Text="Consultation" DataNavigateUrlFields="prev_id"
            DataNavigateUrlFormatString="RoutageView.aspx?adh={0}" />
              <asp:BoundField DataField="AD" HeaderText="AD" SortExpression="AD" />
              <asp:BoundField DataField="Destinataire" HeaderText="Destinataire" SortExpression="Destinataire" />
              <asp:BoundField DataField="Code postal, Ville" HeaderText="Code postal, Ville" SortExpression="Code postal, Ville" />
              <asp:BoundField DataField="Quantite" HeaderText="Quantite" SortExpression="Quantite" />
              <asp:BoundField DataField="Synchrone" HeaderText="Synchrone" SortExpression="Synchrone" />
            </Columns>
              <FooterStyle BackColor="#CCCCCC" />
              <SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
              <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
              <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
              <AlternatingRowStyle BackColor="#CCCCCC" />
          </asp:GridView>
             <asp:Label ID="lblRECHERCHE" runat="server" Width="220px"></asp:Label><br />
          <asp:SqlDataSource ID="SqlDataSource1" runat="server">
          </asp:SqlDataSource>
             <br />
    </div>

    </form>
</body>
</html>
